home *** CD-ROM | disk | FTP | other *** search
- Path: news.interpath.net!mercury!softbase
- From: softbase@mercury.interpath.net (Scott McMahan - Softbase Systems)
- Newsgroups: comp.lang.c
- Subject: Re: [Perf:] mem*() procs vs. array looping
- Date: 28 Feb 1996 13:57:56 GMT
- Organization: Interpath -- Providing Internet access to North Carolina
- Message-ID: <4h1n14$3b3@news.interpath.net>
- References: <4glkq1$gu7@gazette.tandem.com>
- NNTP-Posting-Host: mercury.interpath.com
- X-Newsreader: TIN [version 1.2 PL2]
-
- Francis E. Chang (francis@patch.tandem.com) wrote:
-
- : Are mem*() procedures performance boosters?
-
- I have had some experience with this exact question, and want to
- share what I found out.
-
- 1. The only real answer is, "it depends". It depends on who wrote the
- stdlib routines, how conscientious they were, how much they knew about
- the hardware they were writing on, etc. From one library to the
- next, the answer could change.
-
- 2. The only way to tell is on a per-stdlib basis! Measuring execution
- of the program in a proflier for every different memxxx in every
- different library. You *have* to profile the program and see what
- is going on. Does calling memxxx even matter in the overall scheme?
-
- 3. Most if not all commercial compilers will write things like memcpy
- in assembly language, and some processors have native instructions for
- doing memory copies and stuff that make them much faster than any C
- code you could write, because they don't have to continually load
- addresses like you do in a loop.
-
- 4. I had a program where memset was THE bottleneck, taking up more time
- than I/O. I re-wrote a memory zeroing function using the most unrolled,
- efficient loop I could write, and it was still orders of magnitude
- slower than the system memset. No way I could make it faster in C.
-
- 5. WRT #4, I removed the memset. It was initializing a buffer, and I
- said "forget it" and used the uninitialized buffer and took my chances.
- Changing the design was more effecient than coding hokey
- optimizations! After removing memset, I/O functions accounted for
- 90% or more of the time spent in the program, which I could live with.
-
- Scott
-
-